<template>
  <el-dialog title="项目" :visible.sync="dialogModal" append-to-body>
    <el-form :form="pagination" inline>
      <el-form-item label="项目名称" prop="itemName">
        <el-input v-model="pagination.itemName" maxlength="20" clearable placeholder="请输入项目名称"></el-input>
      </el-form-item>
      <el-form-item prop="itemName">
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" style="width: 100%" @row-click="rowClick">
      <el-table-column prop="name" label="项目名称"></el-table-column>
    </el-table>
    <el-pagination layout="total, prev, pager, next" :total="total" :page-size="pagination.pageSize" :current-page="pagination.pageNum" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  </el-dialog>
</template>
<script>
  import { getProject } from '@/api/auditManagement/projectConfig'
  export default {
    data(){
      return {
        dialogModal: false,
        total: 0,
        pagination: {
          pageNum: 1,
          pageSize: 10,
          itemName: ''
        },
        tableData: []
      }
    },
    methods: {
      getInit(){
        this.dialogModal = true
        this.getList()
      },
      getList(){
        let params = {
          ...this.pagination,
          authorization: localStorage.getItem('authorization'),
          icsAuthorization: localStorage.getItem('icsAuthorization'),
        }
        getProject(params).then(res => {
          this.tableData = res.rows
          this.total = res.total
        })
      },
      search(){
        this.pagination.pageNum = 1
        this.pagination.pageSize = 10
        this.getList()
      },
      rowClick(row){
        this.$emit('update', row)
        this.dialogModal = false
      },
      handleCurrentChange(val){
        this.pagination.pageNum = val
        this.getList()
      },
      handleSizeChange(val){
        this.pagination.pageSize = val
        this.getList()
      }
    }
  }
</script>
<style scoped lang="scss">

</style>
